package com.qft.u_app;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import com.umeng.analytics.MobclickAgent;

import java.util.HashMap;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    private int quantity=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }
    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
        MobclickAgent.onPageStart("MainActivity"); //手动统计页面("SplashScreen"为页面名称，可自定义)
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPause(this);
        MobclickAgent.onPageEnd("MainActivity"); //手动统计页面("SplashScreen"为页面名称，可自定义)，必须保证 onPageEnd 在 onPause 之前调用，因为SDK会在 onPause 中保存onPageEnd统计到的页面数据。
    }

    public void jhn(View view) {
        quantity ++;
        startActivity(new Intent(MainActivity.this,Main2Activity.class));
    }

    public void jhnijjj(View view) {
        /**统计点击行为各属性被触发的次数 **/
        HashMap<String,String> map = new HashMap<String,String>();
        map.put("type1","统计点击行为各属性被触发的次数");
        map.put("quantity1",quantity+"");
        MobclickAgent.onEvent(getApplicationContext(), "1001", map);
        int duration = 12000; //开发者需要自己计算音乐播放时长
        Map<String, String> map_value = new HashMap<String, String>();
        map_value.put("type2" , "开发者需要自己计算音乐播放时长" );
        map_value.put("artist2" , "JJLin" );
        MobclickAgent.onEventValue(this, "1000" , map_value, quantity);
        Toast.makeText(this, quantity+"统计", Toast.LENGTH_SHORT).show();
    }

    public void jjjj(View view) {

    }
}
